using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

namespace hole.battleroyalegame
{
	public class UIGameOverBattleRoyale : MonoBehaviour
	{
		public CanvasGroup background;

		public Text title;

		public Text rankText;

		public Text rewardText;

		public Text killerText;

		[Header("Continue")]
		public CanvasGroup continueGroup;

		public GameObject continueNormalObject;

		public GameObject continueRVObject;

		private int _rank;

		public void Show()
		{
			base.gameObject.SetActive(value: true);
			title.rectTransform.anchoredPosition = new Vector2(0f, 130f);
			background.alpha = 0f;
			background.DOFade(1f, 0.3f).SetDelay(0.8f);
			title.rectTransform.DOAnchorPosY(210f, 0.3f).SetDelay(0.5f);
			rewardText.text = GameManager.InstanceMode.GetStarRewardByRank(_rank).ToString();
			Color white = Color.white;
			int num = 35;
			string key = $"TXT_GAME_POSITION_{_rank}";
			if (_rank == 0)
			{
				white = ColorUtils.HexToColor(16574564u);
				num = 50;
			}
			else if (_rank == 1)
			{
				white = ColorUtils.HexToColor(14806502u);
				num = 45;
			}
			else if (_rank == 2)
			{
				white = ColorUtils.HexToColor(15640170u);
				num = 40;
			}
			else
			{
				white = ColorUtils.HexToColor(13355979u);
				num = 35;
			}
			rankText.text = LocalizationManager.GetTranslation(key);
			rankText.color = white;
			rankText.fontSize = num;
			float num2 = 1.3f;
			continueGroup.interactable = false;
			continueGroup.alpha = 0f;
			continueGroup.DOFade(1f, 0.2f).SetDelay(num2 + 0.5f).OnComplete(delegate
			{
				continueGroup.interactable = true;
			});
			//if (VoodooServiceLocator.Ads.IsRewardedVideoAvailable() && BaseGameManager.Instance.Reward > 1)
			//{
			//	continueNormalObject.SetActive(value: false);
			//	continueRVObject.SetActive(value: true);
			//}
			//else
			//{
			//	continueNormalObject.SetActive(value: true);
			//	continueRVObject.SetActive(value: false);
			//}
		}

		public void SetRank(int rank)
		{
			_rank = rank;
		}

		public void SetVictory(bool b)
		{
			if (b)
			{
				title.text = LocalizationManager.GetTranslation("TXT_GAME_OVER_VICTORY");
			}
			else
			{
				title.text = LocalizationManager.GetTranslation("TXT_GAME_OVER_EATEN");
			}
		}

		public void SetKiller(Hole killer)
		{
			if (killer == null)
			{
				killerText.gameObject.SetActive(value: false);
			}
			else
			{
				killerText.text = string.Format(LocalizationManager.GetTranslation("TXT_GAME_EATEN_BY"), $"<color=#{ColorUtils.ColorToHex(killer.CurrentSkinParameters.mainColor)}>{killer.Pseudo}</color>");
			}
		}
	}
}
